from goods.models import SPUSpecification,SPU
from rest_framework import serializers

class specsserializers (serializers.ModelSerializer):
    # 将默认返回妲id值改为名称
    spu=serializers.StringRelatedField(read_only=True)
    spu_id=serializers.IntegerField() # id 在模型类表中以spu_id妲形式保存,可以根据表字段进行序列化烦恼和

    class Meta:
        model = SPUSpecification
        fields="__all__"



# 为新增商品查询spu商品下拉列表序列化器
class Spuserializer(serializers.ModelSerializer):
    class Meta:
        model=SPU
        fields=("name","id")
